package com.example.binpacking.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.binpacking.model.QuestionnaireItem;
import com.example.binpacking.model.QuestionnaireOption;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.math.BigDecimal;
@Mapper
public interface QuestionnaireOptionMapper extends BaseMapper<QuestionnaireOption> {
    //字段对应有问题
    @Select("SELECT a.*,(select name from tbl_dictionary_item b where b.id=a.itemid) as itemname\n" +
            "            from tbl_dictionary_option a \n" +
            "            where a.itemid='1' and a.isdeleted='0'\n" +
            "           order by a.orderid")
    Page<QuestionnaireOption> selectByDeletedAndItem(Page<QuestionnaireOption> page, @Param("isdeleted") BigDecimal isdeleted, @Param("itemid") BigDecimal itemid);

    @Update("update tbl_dictionary_option set name= #{name} where id= #{id}")
    int updateNameById(@Param("id")BigDecimal id,@Param("name")String name);

    @Update("update tbl_dictionary_option set isdeleted= #{isdeleted} where id= #{id}")
    int updateDeletedById(@Param("id")BigDecimal id,@Param("isdeleted")BigDecimal isdeleted);
}
